package com.ck;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动初始化bean
 * 参考 https://www.jianshu.com/p/0d196ad23915
 * @author timiv
 */
@Configuration
@EnableConfigurationProperties(Properties.class)
public class AutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(Service.class)
    public Service service(Properties properties){
        return new Service(properties);
    }
}
